var setting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "mlsUserId",
            pIdKey: "fid",
            rootPId: -1
        },
        key: {
            url: "nourl"
        }
    }
};
var ztree;


var vm = new Vue({
    el: '#rrapp',
    data: {
        sumAllProfit: null,
        sumGetProfit: null
    },
    created:function() {
    },
    methods: {
    }
});

//展示获取子节点的数目
function getNum(paramLists){
    for (var i=0, l=paramLists.length; i<l; i++) {
        var num = paramLists[i].children ? paramLists[i].children.length : 0;
        paramLists[i].name = "【" + num + "】" + paramLists[i].name;
        ztree.updateNode(paramLists[i]);
        if(num>0){
            getNum(paramLists[i].children)
        };
    }
};


$(function () {
    //加载菜单树
    Ajax.request({
        url: "../mlsuser/queryAll",
        async: true,
        successCallback: function (r) {
            ztree = $.fn.zTree.init($("#menuTree"), setting, r.userList);
            vm.sumAllProfit = r.sumAllProfit;
            vm.sumGetProfit = r.sumGetProfit;

            fuzzySearch('menuTree','#key',null,true); //初始化模糊搜索方法

            getNum(ztree.getNodes());
        }
    });

});


